package weekMatch.one_347;

import java.util.HashSet;
import java.util.Set;

public class LeeCode_02 {
    public static void main(String[] args) {

    }
    private static int[][] differenceOfDistinctValues(int[][] grid) {
        int m = grid.length, n = grid[0].length;
        int[][] ans = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                int ti = i - 1, tj = j - 1;
                Set<Integer> set1 = new HashSet<>();
                Set<Integer> set2 = new HashSet<>();
                while (ti >= 0 && tj >= 0){
                    set1.add(grid[ti][tj]);
                    ti--;
                    tj--;
                }
                ti = i + 1;
                tj = j + 1;
                while (ti < m && tj < n){
                    set2.add(grid[ti][tj]);
                    ti++;
                    tj++;
                }
                ans[i][j] = Math.abs(set1.size() - set2.size());
            }
        }
        return ans;
    }
}
